<!DOCTYPE html>
<html xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"/>
    <title>求职意向</title>
    <link rel="icon" type="image/png" href="/img/icon.png">
    <script type="text/javascript" src="/h5/newall/newall.js"></script>
    <link rel="stylesheet" type="text/css" href="/h5/newall/newall.css">

</head>

<div class="mui-content-padded H5body basedata">
    <div class="topmsg">
        <p class="msgtext">注册填写/上传的信息越全面，客户信任度越高</p>
    </div>
    <MCform id="Form" class="mctag">
        <MCtitle class="mctag" subtitle="新增" subtitleOn="onNewli()">求职意向（公司）</MCtitle>
        <div mcname="qiuzhiyixiangArrayGS" v-for="(obj,key) in qiuzhiyixiangArrayGS" class="content" v-bind:class="{newli:obj.newli}">

            <h4 name="title" class="title">求职意向{{key+1}}</h4>
            <a class="red btn">删除</a>
            <ul class="baseul">
                <li class="li">
                    <p class="title">地点</p>
                    <input type="text" placeholder="请输入"
                           v-model="obj.didian" name="didian"
                           class="mui-input CityPicker">
                </li>
                <li class="li">
                    <p class="title">职位</p>
                    <input type="text" placeholder="请输入"
                           v-model="obj.zhiwei" name="zhiwei"
                           class="mui-input">
                </li>
                <li class="li">
                    <p class="title">期望薪资(人民币)</p>
                    <MCselect :mcname="'qiwangxinshui'+key" v-model="obj.qiwangxinshui" name="qiwangxinshui"
                              :defaultval="obj.qiwangxinshui" class="mui-btn-block mctag mui-input-clear">
                        <option value="">请选择</option>
                        <option value="1">1000元~2000元</option>
                        <option value="2">2000元~5000元</option>
                        <option value="3">5000元~10000元</option>
                        <option value="4">10000元~15000元</option>
                        <option value="5">15000元~30000元</option>
                        <option value="6">30000元以上</option>
                    </MCselect>
                </li>
                <li class="li">
                    <p class="title">工作类型</p>
                    <input type="text" placeholder="请输入"
                           v-model="obj.gongzuoleixing" name="gongzuoleixing"
                           class="mui-input">
                </li>
                <li class="li">
                    <p class="title">行业</p>
                    <input type="text" placeholder="请输入"
                           v-model="obj.hangye" name="hangye"
                           class="mui-input">
                </li>

                <li class="li">
                    <p class="title">到岗时间</p>
                    <input type="text" placeholder="请输入"
                           v-model="obj.daogangshijian" name="daogangshijian"
                           class="mui-input">
                </li>


            </ul>
        </div>
        <button id="submit" type="submit"
                class="mui-btn mui-btn-primary" >
            保存
        </button>
    </MCform>
</div>

<script type="text/javascript" src="/h5/js/all2.js"></script>
<script type="text/javascript" src="/h5/newall/city.data-3.js"></script>
</body>
<style>
    .mctag .content.newli {
        background-color: rgb(222 248 255);
    }

    MCform .content.newli .li mcselect.mctag {
        background-color: rgb(222 248 255);
    }

    MCform .content.newli .li .mui-input {
        background-color: rgb(222 248 255);
    }

    .mctag .content {
        position: relative;
    }

    .mctag .content .red {
        position: absolute;
        top: 0.2rem;
        right: 0;
        font-size: 0.16rem;
    }
</style>
<script>
    var view = new MC.View.MCform('#Form');
    /*view.vue.qiuzhiyixiangArrayGS=[{
        didian:'河南省 新乡市 原阳县'
    }];
    setTimeout(function () {
        view.createEvent();
    }, 2);*/


    MC.apiD('getuser_qiuzhiyixiang_gr', {}, function (json) {
        console.log(json);
        if (json.qiuzhiyixiangArrayGS == null || json.qiuzhiyixiangArrayGS.length == 0) {
            json.qiuzhiyixiangArrayGS = [{
                didian: "",
                zhiwei: '',
                qiwangxinshui: '',
                gongzuoleixing: '',
                hangye: '',
                daogangshijian: '',
            }];
        }
        view.vue.qiuzhiyixiangArrayGS = json.qiuzhiyixiangArrayGS;
        setTimeout(function () {
            view.createEvent();
        }, 2);
    });


    function onNewli() {
        tongbutoview(function () {
                var newlist = {
                    newli: 'newli',
                    didian: "",
                    zhiwei: '',
                    qiwangxinshui: '',
                    gongzuoleixing: '',
                    hangye: '',
                    daogangshijian: '',
                };
                view.vue.qiuzhiyixiangArrayGS.push(newlist);
                console.log('onNewli()');

                setTimeout(function () {
                    $("html").scrollTop($("html")[0].scrollHeight);
                    $("body").scrollTop($("body")[0].scrollHeight);
                    view.createEvent();
                    setTimeout(function () {
                        $("html").scrollTop($("html")[0].scrollHeight);
                        $("body").scrollTop($("body")[0].scrollHeight);
                        newlist.newli = '';
                    }, 800);
                }, 10);
            }
        );
    }

    function tongbutoview(fun) {
        console.log('tongbutoview(fun)');
        var qiuzhiyixiangArrayGS = $('#Form [mcname=qiuzhiyixiangArrayGS]');
        var list = [];
        for (var i = 0; i < qiuzhiyixiangArrayGS.length; i++) {
            var one = $(qiuzhiyixiangArrayGS[i]);
            var didian = one.find('[name=didian]').val();
            var zhiwei = one.find('[name=zhiwei]').val();
            var qiwangxinshui = one.find('[name=qiwangxinshui]').val();
            var gongzuoleixing = one.find('[name=gongzuoleixing]').val();
            var hangye = one.find('[name=hangye]').val();
            var daogangshijian = one.find('[name=daogangshijian]').val();
            list.push({
                title: one.find('[name=title]').text(),
                didian: didian,
                zhiwei: zhiwei,
                qiwangxinshui: qiwangxinshui,
                gongzuoleixing: gongzuoleixing,
                hangye: hangye,
                daogangshijian: daogangshijian,
            });
        }
        view.vue.qiuzhiyixiangArrayGS = [];
        setTimeout(function () {
            view.vue.qiuzhiyixiangArrayGS = list;
            setTimeout(function () {
                fun && fun();
            }, 100);

        }, 10);
    }

    $('.mctag').on('click', '.content .red', function () {
        var content = $(this).parents('.content');
        var title = content.find('[name=title]').text();
        MC.msg.confirm("是否删除(" + title + ")?", function () {
            content.remove();
            // content.add
            setTimeout(function () {
                tongbutoview(function(){
                    view.createEvent();
                });
            }, 100);
        });
    });

    $('#submit').on('click', function () {
        tongbutoview(function () {
            view.createEvent();
            for (var i = 0; i < view.vue.qiuzhiyixiangArrayGS.length; i++) {
                var one = view.vue.qiuzhiyixiangArrayGS[i];
                one.title = '(' + one.title + ')';
                if (!one.didian || one.didian == '') {
                    return MC.msg.alert(one.title + "的地点必须填写");
                }
                if (!one.zhiwei || one.zhiwei == '') {
                    return MC.msg.alert(one.title + "的职位历必须填写");
                }
                if (!one.qiwangxinshui || one.qiwangxinshui == '') {
                    return MC.msg.alert(one.title + "的期望薪水必须填写");
                }
                if (!one.gongzuoleixing || one.gongzuoleixing == '') {
                    return MC.msg.alert(one.title + "的工作类型必须填写");
                }
                if (!one.hangye || one.hangye == '') {
                    return MC.msg.alert(one.title + "的行业必须填写");
                }
                if (!one.daogangshijian || one.daogangshijian == '') {
                    return MC.msg.alert(one.title + "的到岗时间必须填写");
                }
            }
            var json = JSON.stringify(view.vue.qiuzhiyixiangArrayGS);

            console.log(json);
            MC.apiD('setuser_qiuzhiyixiang_gr', {
                qiuzhiyixiangArrayGS: json
            }, function () {
                MC.msg.show('保存成功');
            });
        });
    });

</script>
</body>
</html>